package com.web.ThirdService.Controller;

import com.web.ThirdService.Service.ThirdService;
import entity.Item;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/third/api")
public class ThirdController {
    @Autowired
    ThirdService thirdService;

    @GetMapping("/get")
    public Item deleteFirst(@RequestParam(value = "itemid") Integer itemid) {
        log.info("经过了第三接口");
        return thirdService.getItemById(itemid);
    }

    @GetMapping("/get/fallbackStock")
    public void getFallbackStock(@RequestParam(value = "itemid") Integer itemid,
                                 @RequestParam(value = "num") Integer num) {
        log.info("回滚库存");
        thirdService.fallbackStock(itemid, num);
    }

}
